import { get } from './index'
import { musicApi } from '../utils/config'

const defaultParams = { offset: 0, limit: 10 }

//查询天气
const weather = p => get('/api/simpleWeather/query?key=a66b11d43e320442ca4c1c4e43dc0c5a', p)

//查询位置
const ip = p => get('/api/ip/ipNew?key=0475974d16ba3364a1d59a17ed6763f0', p)

//登录
const login = p => get(musicApi + '/login/cellphone', p)

//推荐新歌
const recomNew = p => get(musicApi + '/personalized/newsong', p)

//热门歌手
const artists = (p = defaultParams) => get(musicApi + '/top/artists', p)

//最新专辑
const newest = p => get(musicApi + '/album/newest', p)
//专辑内容
const albumDteail = p => get(musicApi + '/album', p)

//推荐歌曲 需要登录
const recomSongs = p => get(musicApi + '/recommend/songs', p)

//获取歌曲信息
const getSongs = {
  //获取url
  getUrl(p) {
    return get(musicApi + '/song/url', p)
  },

  //获取歌曲详情
  deail(p) {
    return get(musicApi + '/song/detail', p)
  },

  //判断是否可用
  isSong(p) {
    return get(musicApi + '/check/music', p)
  },

  //获取歌词
  getLyric(p) {
    return get(musicApi + '/lyric', p)
  },

  //获取评论
  getComment(p) {
    return get(musicApi + '/comment/music', p)
  },
}

//歌手热门歌曲
const artistsSongs = p => get(musicApi + '/artists', p)

const search = p => get(musicApi + '/cloudsearch', p)

export { search, weather, ip, login, recomNew, artists, newest, recomSongs, albumDteail, getSongs, artistsSongs }

//壁纸
export const wallpaper = {
  //获取分类列表
  getClassifyList() {
    return get('/360/index.php?c=WallPaper&a=getAllCategoriesV2&from=360chrome')
  },

  //获取列表
  getList(params) {
    return get('/360/index.php?c=WallPaper&a=getAppsByCategory&from=360chrome', { ...params })
  },
}
